import BuffUtil from '@/BuffUtil';
import TalentBase from 'code/Scripts/Abilities/base/TalentBase';
const desc = `每当杀死一个单位，会收集其灵魂为你所用，每个灵魂增加${ColorSafe}2|r点攻击和法强。灵魂上限为${ColorSafe}等级x2|r。|n觉醒效果：灵魂上限翻倍，变为${ColorSafe}等级x4|r`;
const art = 'ReplaceableTextures\\CommandButtons\\BTNShade.blp';
const name = '收集灵魂';
const config: TalentConfigModel = {
    id: 'talent_t_TalentCollectSoul',
    name,
    desc,
    art,
    buffType: {
        id: 'buff_t_TalentCollectSoul',
        art,
        name,
        ubertip: desc,
        attribute: {
            attack: 2,
            法术强度: 2,
        },
        stackCountMax: -1,
    },
    buffTypePlus: {
        id: 'buff_t_TalentCollectSoul_plus',
        art,
        name: '',
        ubertip: `每当杀死一个单位，会收集其灵魂为你所用，每个灵魂增加${ColorSafe}2|r点攻击和法强。灵魂上限为${ColorSafe}等级x4|r`,
        stackCountMax: -1,
        attribute: {
            attack: 2,
            法术强度: 2,
        },
    },
};
export default class TalentCollectSoul extends TalentBase {
    static instance: TalentCollectSoul;
    constructor(p?: TalentConfigModel) {
        super(p);
        TalentCollectSoul.instance = this;
        this.setTalentConfig(config);
        EventManager.单位死亡(this.onKillEnemy);
        this.onAddTalentPlus(this.addTalentPlusEffect);
    }
    addTalentPlusEffect<T extends TalentBase = TalentCollectSoul>(u: unit, talent: T, data: TalentPlusData) {
        data.newBuff.stackCount = data.prevBuff.stackCount;
    }
    onKillEnemy(d: DamageEventData) {
        let _this = TalentCollectSoul.instance;
        let { unEffect, plus } = _this.talentUnEffect(d.source);
        if (unEffect) return;
        let lv = GetHeroLevel(d.source);
        let max = plus ? lv * 4 : lv * 2;
        let id = plus ? _this.buffTypePlus.id : _this.buffType.id;
        let buff = BuffUtil.getUnitBuff(d.source, id);
        if (buff.stackCount < max) {
            buff.stackCount += 1;
        }
    }
}
